﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>主框架页面</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <link rel="shortcut icon" href="/images/favicon.ico" />
    <link href="/css/fyyui.css" rel="stylesheet" />
    <script src="/js/jquery.js"></script>
    <script src="/js/fyyui.js"></script>
    <script type="text/javascript">

        function fmt(item, field) {
            if (field == 'edu') {
                switch (item.edu) {
                    case 1: return "专科";
                    case 2: return "本科";
                }
            } else if (field == 'major') {
                switch (item.major) {
                    case 1: return "计算机";
                    case 2: return "软件工程";
                }
            }
        }

        function onclick(item, opcode) {
            switch (opcode) {
                case "edit": {
                    gotoPage('add.html?id=' + item.id);
                    return;
                }
                case "delete": {
                    showAskPopup({ id: item.id });
                    return;
                }
                case "view": {
                    gotoPage('view.html?id=' + item.id);
                    return;
                }
            }
        }

        $(function () {
            initList({
                id: 'custlist',
                fields: [
                    { code: "name", name: "姓名", minWidth: 100, format: false },
                    { code: "edu", name: "学历", minWidth: 100, format: true },
                    { code: "major", name: "专业", minWidth: 100, format: true }
                ],
                ops: "edit,view,delete"
            });

            queryList({
                id: 'custlist',
                url: '/api/Cust/GetCustList',
                fmt: fmt,
                ops: [
                    { name: "编辑", code: "edit" },
                    { name: "删除", code: "delete" },
                    { name: "查看", code: "view" }
                ],
                click: onclick
            });

            initSelect({
                id: 'seledu',
                text: '教育程度',
            });

            bindSelect({
                id: 'seledu',
                ds: [
                    { name: "本科", code: "1" },
                    { name: "专科", code: "2" }
                ]
            });

            initAskPopup({
                id: 'delpopup',
                title: '删除确认',
                content: '确认删除数据吗？',
                ok: function (_props) {
                    console.log(_props);
                    doDelete({
                        url: '/api/Cust/DelCust',
                        props: _props,
                        callback: query
                    });
                },
                close: function () {

                }
            });
        });

        function query() {
            var key = $('#txtkey').val();
            var edu = $('#seledu').attr('f-value');
            queryListOptions.custlist.props = {};
            if (key.trim() != '') {
                queryListOptions.custlist.props['name'] = key;
            }

            if (edu != '') {
                queryListOptions.custlist.props['edu'] = edu;
            }
            
            queryList(queryListOptions.custlist);
        }

    </script>
</head>
<body>
    <div class="f-toolbar">
        <input type="text" id="txtkey" class="f-txtbox f-left" placeholder="姓名" />
        <div class="f-mclear"></div>
        <div id="seledu" class="f-select f-left"></div>
        <div class="f-mclear"></div>
        <input type="button" class="f-button f-left" value="查询" onclick="query();" />
        <div class="f-clear"></div>
    </div>
    <div id="custlist" class="f-table-container">
    </div>
    <div id="delpopup" class="f-ask-popup">
    </div>
    <div class="f-popup-shade"></div>
</body>
</html>